package com.googlecode.hmvc4gwt.example.hmvcblog.server.domain.blog;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.googlecode.hmvc4gwt.example.hmvcblog.server.domain.text.ITextblock;

@Entity
@NamedQueries({
	@NamedQuery(name="BlogEntryComment.findByBlogEntry", query="SELECT blogEntryComment FROM BlogEntryComment blogEntryComment WHERE blogEntryComment.blogEntry = ?1")
})

public class BlogEntryComment implements ITextblock {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * contians the name of the author of the Comment
	 */
	private String authorName;
	
	/**
	 * contains the related BlogEntry
	 */
	private BlogEntry blogEntry;
	
	/**
	 * contains the date of the Comment 
	 */
	private Date date;
	
	/**
	 * the id
	 */
	private int id;

	/**
	 * the text of the Comment
	 */
	private String text;

	@Column(nullable=false)
	public String getAuthorName() {
		return authorName;
	}
	
	@ManyToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
	public BlogEntry getBlogEntry() {
		return blogEntry;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable=false)
	public Date getDate() {
		return date;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public String getText() {
		return text;
	}

	public void setAuthorName(String authorName) {
		this.authorName = authorName;
	}
	
	public void setBlogEntry(BlogEntry blogEntry) {
		this.blogEntry = blogEntry;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setText(String text) {
		this.text = text;
	}

}
